package com.jd.dl.pojo;

import java.util.ArrayList;
import java.util.List;

import com.googlecode.jsonplugin.annotations.JSON;

public class Dictionary implements java.io.Serializable {

	private static final long serialVersionUID = -9073242649704266829L;

	private Long dictionaryId;

	private String dictionaryName;
	private String description;
	private String code;
	private Integer level;
	private Dictionary parentDictionary;
	private List<Dictionary> children;

	public Long getDictionaryId() {
		return dictionaryId;
	}

	public void setDictionaryId(Long dictionaryId) {
		this.dictionaryId = dictionaryId;
	}

	public String getDictionaryName() {
		return dictionaryName;
	}

	public void setDictionaryName(String dictionaryName) {
		this.dictionaryName = dictionaryName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@JSON(serialize = false)
	public Dictionary getParentDictionary() {
		return parentDictionary;
	}

	public void setParentDictionary(Dictionary parent) {
		this.parentDictionary = parent;
	}

	@JSON(serialize = false)
	public List<Dictionary> getChildren() {
		return children;
	}

	public void setChildren(List<Dictionary> children) {
		this.children = children;
	}

	public List toList() {
		List info = new ArrayList<Object>();
		info.add(dictionaryId);
		info.add(dictionaryName);
		info.add(code);
		info.add(description);
		info.add(level);// level
		if (parentDictionary != null) {
			info.add(parentDictionary.getDictionaryId());// parent
		} else {
			info.add(0);
		}
		info.add(children == null || children.size() == 0);// isleaf
		info.add(false); // expanded
		return info;
	}

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}
}
